package com.hskn.hss.utils;

public class Save {
    private final int n = 5;// 确定数组大小，即要保存几个数
    private int[] a = new int[n];// 创建数组
    private int x = 0;// 指定可替换位置

    // 方法：添加
    public void add(int y) {
        if (x == n) x = 0;
        a[x] = y;
        x++;
    }

    // 方法：显示数组
    public void display() {
        for (int i = x; i > 0; i--) {
            System.out.print(a[i - 1] + " ");
        }
        for (int j = n; j > x; j--) {
            System.out.print(a[j - 1] + " ");
        }
        System.out.println();
    }
}
